<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<%@include file="../common/includeBaseSet.jsp" %>
<%@include file="../../common/includeSystemSet.jsp" %>
<%@include file="../../common/operation_forbid.jsp" %>
<link href="${jypath}/resources/css/upload.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    
	$(function(){
		getList();
		selectNonpaymentNum();
	});

	function addProjectType(){
		location.href="${jypath}/system/resources/list";
	}
	var isSubmit=false;
	function clearNote(url,title, type){
		//清空
		$("textarea[name='content']").html(""); 
		$("input[name='title']").val(""); 
		$("select option").attr("selected",false);
		$("select option[value='qxz']").attr("selected",true);
		
		addNotice(url,title, type);
	}
	
	function addNotice(url,title, type){
		if("detail" == type){
			JY.Model.detail("addNoticeDiv",title,function(){
				 if(JY.Validate.form("addNoticeForm")){
					 var that =$(this);
					 JY.Ajax.doRequest("addNoticeForm",url,null,function(data){
						layer.msg(data.resMsg);
						that.dialog("close"); 
						getList();
					 });
				 }
			});
		}else if("edit" == type){
			JY.Model.editBig("addNoticeDiv",title,function(){
				 if(JY.Validate.form("addNoticeForm")){
					 var that =$(this);
					 if(isSubmit){
						 layer.msg("不能重复提交");
						 return;
					 }
					 isSubmit=true;
					 JY.Ajax.doRequest("addNoticeForm",url,null,function(data){
						isSubmit=false;
						layer.msg(data.resMsg);
						that.dialog("close"); 
						getList();
					 });
				 }
			});
		}
	}
	
	function edit(id){
		JY.Ajax.doRequest(null,"${jypath}/system/notice/view?id="+id,null,function(data){
			$("textarea[name='content']").html(data.obj.content); 
			$("select option[value='"+data.obj.projectCode+"']").attr("selected","selected");
			$("input[name='title']").val(data.obj.title); 
			$("select option[value='"+data.obj.dictionaryId+"']").attr("selected","selected");
			addNotice("${jypath}/system/notice/edit?id="+id,"修改公告", "edit");
		});
	}
	
	function detail(id){
		JY.Ajax.doRequest(null,"${jypath}/system/notice/view?id="+id,null,function(data){
			$("textarea[name='content']").html(data.obj.content); 
			$("select option[value='"+data.obj.projectCode+"']").attr("selected","selected");
			$("input[name='title']").val(data.obj.title); 
			$("select option[value='"+data.obj.dictionaryId+"']").attr("selected","selected");
			addNotice("${jypath}/system/notice/edit?id="+id,"查看公告", "detail");
		});
	}
	
   function del(id){
	   JY.Ajax.doRequest(null,"${jypath}/system/notice/delete?id="+id,null,function(data){
		   $("#baseTable tbody").empty();
		   getList();
		   layer.msg(data.resMsg);
			
	   });
   }
	
	function getList(){
		JY.Ajax.doRequest("baseForm",jypath +'/system/notice/list',{noticeType:'NC',delFlag:'0'},function(data){
			 var permitBtn=new Array();
			var obj='${btnJson}';
			var objList = JSON.parse(obj);
			for(ob in objList ){
				if(objList[ob].permission=='system:notice:edit'){
					permitBtn.push({name:"修改",btnFun:"edit",icon:"icon-edit color-blue"});
				}else if(objList[ob].permission=='system:notice:delete'){
					permitBtn.push({name:"删除",btnFun:"del",icon:"icon-remove-sign color-red"});
				}else if(objList[ob].permission=='system:notice:list'){
					permitBtn.push({name:"查看",btnFun:"detail",icon:"icon-zoom-in color-purple"});
				}
			}
			//onclick='detail("+l.id+");'
			 $("#baseTable tbody").empty();
			 var page=data.obj;
			 //数据集合
        	 var results=page.rows;
			 
        	 //分页数据
         	 var pageNum=page.pageNumber,pageSize=page.pageSize,totalRecord=page.total;
         	 var html="";
         	 if(results!=null&&results.length>0){
        		 var leng=(pageNum-1)*pageSize;//计算序号
        	
        		 for(var i = 0;i<results.length;i++){
        		
        			 var l=results[i];
        			 //var aBut="<a href='javascript:edit("+l.id+")'></a>";
        			 var content=l.content;
        			 var titleContent = content;
        			 if(l.content.length>30){
        				 content=l.content.substring(0,30)+"....";
        			 }
        			 //html+="<tr><td class='center'>"+JY.Object.notEmpty(content)+aBut+"</td>";
        			 html+="<tr><td class='center'  title='"+JY.Object.notEmpty(titleContent)+"'><a href='javascript: void(0);'>"+JY.Object.notEmpty(content)+"</a></td>";
        			 html+="<td class='center'>"+JY.Object.notEmpty(l.title)+"</td>";
        			 html+="<td class='center'>"+JY.Object.notEmpty(l.dicCN)+"</td>";
        			 html+="<td class='center'>"+JY.Object.notEmpty(l.projectCN)+"</td>";
        			 html+="<td class='center'>"+JY.Object.notEmpty(new Date(l.issueTime).Format("yyyy-MM-dd"))+"</td>";
        			 html+=JY.Tags.setFunction(l.id,permitBtn);
        			 html+="</tr>";
        		 }
        		 $("#baseTable tbody").append(html);
        		 JY.Page.setPage("baseForm","pageing",pageSize,pageNum,totalRecord,"getList");
        	 }else{
        			html+="<tr><td colspan='10' class='center'>没有相关数据</td></tr>";
            		$("#baseTable tbody").append(html);
            		$("#pageing ul").empty();//清空分页
        	 }
        	 JY.Model.loadingClose();
		});
	}
	
	
	//日期格式化
	Date.prototype.Format = function (fmt) { 
	    var o = {
	        "M+": this.getMonth() + 1, //月份 
	        "d+": this.getDate(), //日 
	        "h+": this.getHours(), //小时 
	        "m+": this.getMinutes(), //分 
	        "s+": this.getSeconds(), //秒 
	        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
	        "S": this.getMilliseconds() //毫秒 
	    };
	    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	    for (var k in o)
	    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	    return fmt;
	}
	
	function remindSetting(){
		var url = jypath + "/system/msgSetting/edit";
		JY.Model.editBig("RE07Div","消息提醒设置",function(){
			if(JY.Validate.form("RE07Form")){
			 	var that =$(this);
			 	JY.Ajax.doRequest("RE07Form",url,null,function(data){
					layer.msg(data.resMsg);
					that.dialog("close"); 
			 	}); 
		 	}
		});
		$("#RE07Form select[name='RE07TempType']").val("7");
	}
	
	function changeTmpeType(tempType, tempId, tempDiv){
		var selValue = $("#"+tempId).val();
		var url = jypath + "/system/msgSetting/edit";
		if(selValue != tempType){
			if(selValue == '4'){
				$("#"+tempDiv).dialog("close");
				JY.Model.editBig("RE04Div","消息提醒设置",function(){
					if(JY.Validate.form("RE04Form")){
						var that =$(this);
						var attackTime = $("#RE04Form input[name='attackTime']").val();
						var limitDays = $("#RE04Form input[name='limitDays']").val();
						if(parseInt(attackTime) > parseInt(limitDays)){
							that.tips({side:1,msg : "未跟进时间不能大于被分配时间！",bg:'#FF2D2D',time:1});
							return;
						}
						JY.Ajax.doRequest("RE04Form",url,null,function(data){
							layer.msg(data.resMsg);
							that.dialog("close"); 
							getList();
					 	});
				 	}
				});
				$("#RE04Form select[name='RE04TempType']").val(selValue);
			}else if(selValue == '7'){
				$("#"+tempDiv).dialog("close");
				JY.Model.editBig("RE07Div","消息提醒设置",function(){
					if(JY.Validate.form("RE07Form")){
					 	var that =$(this);
					 	JY.Ajax.doRequest("RE07Form",url,null,function(data){
							layer.msg(data.resMsg);
							that.dialog("close"); 
							getList();
					 	}); 
				 	}
				});
				$("#RE07Form select[name='RE07TempType']").val(selValue);
			}else if(selValue == '8'){
				$("#"+tempDiv).dialog("close");
				JY.Model.editBig("RE08Div","消息提醒设置",function(){
					 if(JY.Validate.form("RE08Form")){
						 var that =$(this);
						 JY.Ajax.doRequest("RE08Form",url,null,function(data){
							layer.msg(data.resMsg);
							that.dialog("close"); 
							getList();
						 }); 
					 }
				});
				$("#RE08Form select[name='RE08TempType']").val(selValue);
			}
		}
	}
	
	function noticeList(dicValue){
		location.href="${jypath}/system/notice/toNoticeList?dicValue="+dicValue;
	}
	
	//查询签约回款提醒数量
	function selectNonpaymentNum(){
		$.ajax({
			type: 'post',
            url: '${jypath}/backstage/selectNonpaymentNum',
            data:{},
            dataType: 'json',
            success: function(data){
            	if(data.res == "1"){
            		$("#nonpaymentNum").text(data.obj);
            	}
            }
        });
	}
	//跳转签约回款提醒列表
	function toNonpaymentList(){
        var tabKey = "nonpayment";
        var url = "/backstage/toNonpaymentList";
        parent.openMenu('0', tabKey, '', '签约回款提醒', url)
	}
    //逾期未签约提醒
    function toOverdueSignedList(){
        var tabKey = "overdueSigned";
        var url = "/backstage/toOverdueSignedList";
        parent.openMenu('0', tabKey, '', '逾期未签约', url)
    }
    //逾期未付款提醒
    function toOverduePaymentList(){
        var tabKey = "overduePayment";
        var url = "/backstage/toOverduePaymentList";
        parent.openMenu('0', tabKey, '', '逾期未付款', url)
    }
</script>
</head>
<body >
	
	<div class="homewrap"> 

    <div class="maintt2"> 
      <p class=" cell cell1">
      	<img src="${jypath}/resources/images/icon_say.png" />
      </p> 
      <p class=" cell cell2 clearfix">
      	<span class="left">消息提醒</span>
   		<a class="right">
      	<img src="${jypath}/resources/images/icon_set.png" />
      	<em id="remindSetting" onclick="remindSetting();">设置</em>
      	</a>
      </p>
    </div>

   <ul class="manue_list clearfix">
       <li onclick="toNonpaymentList();">
           <p class="cell cell1 bg1"> <img src="${jypath}/resources/images/icon_5.png" /> </p>
           <div class=" cell">
               <p> 签约回款提醒 </p>
               <p id="nonpaymentNum" class="qing f18"> 0 </p>
           </div>
       </li>
       <li onclick="toOverdueSignedList();">
        <p class="cell cell1 bg1"> <img src="${jypath}/resources/images/icon_1.png" /> </p>
        <div class=" cell">
          <p> 逾期未签约 </p>
          <p class="qing f18"> ${ overdueSignedListCount } </p>
        </div>
     </li>
     <li onclick="toOverduePaymentList();">
        <p class="cell cell1 bg1"> <img src="${jypath}/resources/images/icon_2.png" /> </p>
        <div class=" cell">
          <p> 逾期未付款 </p>
          <p class="qing f18"> ${ overduePaymentListCount } </p>
        </div>
     </li>
     <%--li onclick="noticeList('RE03');">
        <p class="cell cell1 bg2"> <img src="${jypath}/resources/images/icon_3.png" /> </p>
        <div class=" cell">
          <p> 待处理客户</p>
          <p class="qing f18"> ${RE03 } </p>
        </div>
     </li>
     <li onclick="noticeList('RE04');"> 
        <p class="cell cell1 bg2"> <img src="${jypath}/resources/images/icon_3.png" /> </p>
        <div class=" cell">
          <p> 客户维护 </p>
          <p class="qing f18"> ${RE04 } </p>
        </div>
     </li--%>
<!--      <li onclick="noticeList('RE05');">  -->
<%--         <p class="cell cell1 bg3"> <img src="${jypath}/resources/images/icon_4.png" /> </p> --%>
<!--         <div class=" cell"> -->
<!--           <p> 审核结果 </p> -->
<%--           <p class=" gray f18"> ${RE05 } </p> --%>
<!--         </div> -->
<!--      </li> -->
<!--      <li onclick="noticeList('RE06');">  -->
<%--         <p class="cell cell1 bg3"> <img src="${jypath}/resources/images/icon_5.png" /> </p> --%>
<!--         <div class=" cell"> -->
<!--           <p> 审核申请 </p> -->
<%--           <p class="gray f18"> ${RE06 } </p> --%>
<!--         </div> -->
<!--      </li> -->
     <%--li onclick="noticeList('RE07');">
        <p class="cell cell1 bg4"> <img src="${jypath}/resources/images/icon_6.png" /> </p>
        <div class=" cell">
          <p> 客户关怀 </p>
          <p class="qing f18"> ${RE07 } </p>
        </div>
     </li-->
<!--      <li onclick="noticeList('RE08');">  -->
<%--         <p class="cell cell1 bg4"> <img src="${jypath}/resources/images/icon_7.png" /> </p> --%>
<!--         <div class=" cell"> -->
<!--           <p> 员工关怀 </p> -->
<%--           <p class="gray f18"> ${RE08 } </p> --%>
<!--         </div> -->
<!--      </li> -->
     <%--  <li onclick="noticeList('RE09');">
        <p class="cell cell1 bg5"> <img src="${jypath}/resources/images/icon_8.png" /> </p>
        <div class=" cell">
          <p> 认筹/认购/签约通知 </p>
          <p class="qing f18"> ${RE09 } </p>
        </div>
     </li> --%>
   </ul>
	<div class="maintt2 mt20"> 
      <p class=" cell cell1">  <img src="${jypath}/resources/images/icon_maill.png" /> </p> 
      <div class=" cell cell2 clearfix"> 
		<span class=" left"> 项目公告栏 </span> 
        <p class=" right"> 
        <c:forEach var="btn" items="${permitBtn}">
        	<c:choose>
        		<c:when test="${btn.permission=='system:notice:add'}">
        		<a href="javascript:clearNote('${jypath}/system/resources/saveNotice','写公告', 'edit')"> <img src="${jypath}/resources/images/icon_whrite.png" /> <em> 写公告 </em> </a> 
        		</c:when>
        		<c:when test="${btn.permission=='estate:noticeType:add'}">
        		<a class=" ml15" href="javascript:void(0)" onclick="addProjectType()"> <img src="${jypath}/resources/images/icon_set.png" /> <em> 设置 </em> </a>
        		</c:when>
        	</c:choose>
        </c:forEach>
         </p>
	  </div>
    </div>
</div>
    

		 <div class="page-content">
	
		<div class="row-fluid">	
			<div class="col-xs-12">
			
			<form id="baseForm" class="form-inline" method="POST" onsubmit="return false;">
				<input type='hidden' class='pageNum' name='pageNum' value='1'/>
				<input type='hidden' class='pageSize'  name='pageSize' value='5'/>
			</form>
			
    <table id="baseTable" class="table table-striped table-bordered table-hover" >
		<thead>
			<tr>
				<!-- <th style="width:1%" class="center">
					<label><input type="checkbox" class="ace" ><span class="lbl"></span></label>	
				</th> -->
				<th class="center">内容</th>
				<th class="center">标题</th>
				<th class="center">类别</th>
				<th class="center">项目</th>
                <th class="center">发布日期</th>
                <th class="center">操作</th>
			</tr>
		</thead>
		<tbody></tbody>
	</table>
	<div class="row">
		<div class="col-sm-12">
			<!--设置分页位置-->
			<div id="pageing" class="dataTables_paginate paging_bootstrap">
				<ul class="pagination"></ul>
			</div>
		</div>
	</div>
	<%@include file="addNoticeForm.jsp" %>
	<!-- 客户维护 -->
	<%@include file="remind_cus_manage.jsp" %>
	<!-- 员工关怀 -->
	<%@include file="remind_user_care.jsp" %>
	<!-- 客户关怀 -->
	<%@include file="remind_cus_care.jsp" %>
</div></div></div>

					
</body>
</html>